<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.bjfu.gmms.model.Pairing" %>

<html>
<head>
    <title>查询结果</title>
    <style>
        body {
            background-color: #f5f5ff;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            position: relative;
        }

        h1 {
            color: #6a4c9c;
            text-align: center;
            padding: 20px;
            background-color: #dcd0e1;
            margin: 0;
        }

        table {
            width: 90%;
            margin: 30px auto;
            border-collapse: collapse;
            background-color: #fff;
            box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
        }

        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #e8d3f5;
            color: #6a4c9c;
        }

        tr:nth-child(even) {
            background-color: #f9f5fa;
        }

        tr:hover {
            background-color: #e1d1f1;
        }

        td {
            color: #4a4a4a;
        }

        /* 按钮样式 */
        .button {
            padding: 10px 20px;
            font-size: 16px;
            color: white;
            background-color: #6a4c9c;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            margin: 10px;
            width: 120px; /* 统一宽度 */
            text-align: center;
        }

        .button:hover {
            background-color: #563b7c;
        }

        /* 右上角按钮容器 */
        .button-container {
            position: absolute;
            top: 20px;
            right: 20px;
            display: flex;
            justify-content: flex-end;
            align-items: center;
        }
    </style>
</head>
<body>
<h1>公示结果</h1>

<%-- 获取 session 中存储的 role --%>
<%
    String role = (String) session.getAttribute("role");
    if (role != null && role.equals("as")) {  // 判断角色是否为 "as"
%>
<div class="button-container">
    <form action="publishServlet" method="post" style="display:inline;">
        <button class="button" name="action" value="publish">发布</button>
    </form>
    <form action="publishServlet" method="post" style="display:inline;">
        <button class="button" name="action" value="cancelPublish">取消发布</button>
    </form>
</div>
<%  } %>

<table border="1">
    <thead>
    <tr>
        <th>学院名称</th>
        <th>一级学科</th>
        <th>二级学科</th>
        <th>导师姓名</th>
        <th>研究方向</th>
        <th>学生姓名</th>
    </tr>
    </thead>
    <tbody>
    <%
        // 获取 session 中存储的 pairingList
        List<Pairing> pairingList = (List<Pairing>) session.getAttribute("pairingList");
        if (pairingList != null) {
            for (Pairing pairing : pairingList) {
    %>
    <tr>
        <td><%= pairing.getCollegeName() %></td>
        <td><%= pairing.getPrimaryDisciplineName() %></td>
        <td><%= pairing.getSecondaryDisciplineName() %></td>
        <td><%= pairing.getMentorName() %></td>
        <td><%= pairing.getResearchName() %></td>
        <td><%= pairing.getStudentName() %></td>
    </tr>
    <%
            }
        }
    %>
    </tbody>
</table>
</body>
</html>